草庐IT

python - 为 Python 2.7 安装 MySQL-python 模块时出错

全部标签

ruby - 无法安装metric_fu,如何切换到simplecov?

我尝试在我的Ruby1.9环境中安装metric_fu,但由于以下问题而失败:$geminstallmetric_fu...Fetching:rcov-1.0.0.gem(100%)Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingmetric_fu:ERROR:Failedtobuildgemnativeextension./Users/xxx/.rvm/rubies/ruby-1.9.2-p290/bin/rubyextconf.rb****Ruby1.9isnotsupported.Please

ruby - 扩展模块和类变量访问?

我无法理解为什么在以下示例中访问模​​block的类变量失败:moduleM@@xyz=123endM.class_variables#[:@@xyz]M.class_variable_get:@@xyz#123,sofarsogoodclassCextendMendC.singleton_class.class_variables#[:@@xyz]C.singleton_class.class_variable_get:@@xyz#NameError:#uninitializedclassvariable@@xyzinClass谁能解释为什么类变量@@xyz在C的单例类中突然无法访问

ruby - YARD:记录由包含的模块添加的类方法

我正在使用YARD为我的ruby​​gem编写文档.在我的gem中,我有一些代码遵循这种常见的ruby​​模式,其中一个模块包含在一个类中,并且该模块不仅添加了实例方法,还添加了类方法:moduleMoodefself.included(klass)klass.extendClassMethodsendmoduleClassMethodsdefhelloputs"hello"endendendclassFooincludeMooendFoo.hello#=>classmethodruns,printing"hello"默认情况下,YARD将为Foo类生成如下所示的文档:我认为此文档不充

ruby - 如何在 Sinatra 中制作模块化助手

我想在一个模块中创建一个方法(出于分组原因),它可以作为module.method调用,如下所示:helpersdomoduleUserSessiondeflogged_in?notsession[:email].nil?enddeflogout!session[:email]=nilendendend但是当我尝试使用UserSession.logged_in?调用它时,它说logged_in不是UserSession的方法undefinedmethod`logged_in?'forUserSession:Module当我将方法移动为UserSession的方法时:helpersdom

ruby - 如何选择要在 Ruby 中动态包含的模块版本?

我正在编写一个使用fileutils的小型Rub​​y命令行应用程序来自文件操作的标准库。根据用户调用应用程序的方式,我想包括FileUtils,FileUtils::DryRun或FileUtils::Verbose.自include虽然是私有(private)的,但我无法将选择逻辑放入对象的initialize中方法。(这是我的第一个想法,从那时起我就可以将有关用户选择的信息作为参数传递给new。)我想出了两个似乎可行的选项,但我对其中任何一个都不满意:根据用户的选择在应用程序的命名空间中设置一个全局变量,然后在类中执行条件包含:classWorkercaseApp::OPTION

ruby-on-rails - 覆盖由同一模块中的类方法定义的 ActiveSupport::Concern 模块中的方法

我有一个ActiveSupport::Concern模块,大致如下所示:moduleMyModelmoduleAcceptanceextendActiveSupport::Concernincludeddoenumstatus:[:declined,:accepted]enddefdeclined!self.status=:declined#someextralogicself.save!enddefaccepted!self.status=:accepted#someextralogicself.save!endendend这只会被包含到ActiveRecord类中,因此使用enum

ruby-on-rails - 使用基于已安装引擎的 url_for 获取基于约束的 url

有什么方法可以让url_for在Action调度路由期间根据request.host返回url吗?mountCollaborate::Engine=>'/apps/collaborate',:constraints=>{:host=>'example.com'}mountCollaborate::Engine=>'/apps/worktogether'示例:当用户在example.com主机上时collaborate_path=>/apps/collaborate当用户在任何其他主机上时collaborate_path=>/apps/worktogether经过大量研究,我意识到Rou

ruby - 模块化、基于组件的 Sinatra 应用程序的架构

我正在开发一个包含大约10个不同功能组件的Sinatra应用程序。我们希望能够将这些组件混合并匹配到应用程序的单独实例中,完全从config.yaml文件配置,如下所示:components:-route:'/chunky'component_type:FoodListercomponent_settings:food_type:baconmax_items:400-route:'places/paris'component_type:Mappercomponent_settings:latitude:48.85387273165654longitude:2.340087890625-

ruby - 动态模块 : Querying tables with secondary index

我正在使用gemaws-sdk-ruby查询看起来像这样的表:hk(Hashkey)|guid(Rangekey)|Timestamp(SecondaryRangeindex)|otherattributesaaaa|50|2013-02-04T12:33:00Z|aaaa|244|2013-04-22T04:54:00Z|aaaa|342|2013-05-18T06:52:00Z|bbbb|243|2013-06-21T13:17:00Z|我想要做的是获取在特定日期之后创建的所有“aaaa”行。例如:AWS.config(access_key_id:'xxx',secret_acce

ruby - bundle 安装错误 - 你的 bundle 只支持平台 [] 但你的本地平台是 ["ruby", "x86_64-linux"]

在执行bundle安装时出现此错误;谷歌似乎是一个常见问题,但我似乎找不到解决方法(似乎是关于Gemfile.lock的建议,但我将该文件移到了另一个目录)#bundleinstallYourbundleonlysupportsplatforms[]butyourlocalplatformsare["ruby","x86_64-linux"],andthere'snocompatiblematchbetweenthosetwolists.这是我的Gemfile,目录中没有Gemfile.lock。[root@ip-172-30-4-16rails]#gem-v2.6.11[root@i